<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="utf-8">
    <title>SQE报表查询</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta content="no-cache, no-store, must-revalidate" http-equiv="Cache-Control"/>
    <meta content="no-cache" http-equiv="Pragma"/>
    <meta content="0" http-equiv="Expires"/>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=8">
    <meta http-equiv="Expires" content="0">
    <meta http-equiv="Pragma" content="no-cache">
    <meta http-equiv="Cache-control" content="no-cache">
    <meta http-equiv="Cache" content="no-cache">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <link rel="stylesheet" href="../styles/base.css"/>
    <link rel="stylesheet" href="../styles/common.css"/>
    <link rel="stylesheet" href="../styles/font/iconfont.css"/>
    <link rel="stylesheet" href="../jqueryNicepage/css/layui.css"  media="all">
    <style>
        .body{
            background:#ddecf5;
            min-width: 0px;
           /* overflow: hidden;*/
        }
        .seachHeader span{
            margin-top: 5px;
            float: left;
            display: inline-block;
            height:30px;
            line-height: 30px;
            font-size: 16px;

        }
        .seachHeader span:first-child{
            margin-left: 20px;
        }
        .seachHeader .inputBox{
            float:left;
            width:200px;
            height:30px;
            line-height: 30px;
            font-size: 14px;
            padding-left: 10px;
            position: relative;
        }
        .seachHeader .inputBox input{
            width:190px;
            height:30px;
            line-height: 30px;
            position: absolute;
            padding-left: 10px;
            left:0;
        }
        .searchSureButton,.searchSureBtn{
            margin-left: 30px;
            float:right;
            background-color: #eee;
            font-family: 'Open Sans', sans-serif;
            font-size: 14px;
            text-decoration: none;
            font-weight: 600;
            color: #333;
            position: relative;
            padding: 1px 15px;
            margin-right: 15px;
            margin-top:2px;
            border-top-right-radius: 10px;
            border-bottom-right-radius: 10px;
            border-top-left-radius: 10px;
            border-bottom-left-radius: 10px;
            background-image: -webkit-gradient( linear, left bottom, left top, color-stop(0, rgb(242,242,242)), color-stop(1, rgb(242,242,242)) );
            cursor: pointer;
            overflow: hidden;
        }
        .searchSureButton:hover,.searchSureBtn:hover{
            color:#fff;
            background:#40E0D0;
        }
        .searchContainer{
            width:96%;
            max-height: 96%;
            min-height: 96%;
            margin-left: 2%;
            margin-top:10px;
            min-width: 1200px;
            position:relative;

        }
       .centerInput{
           margin-right: 10px;
       }
        .td0 a{
            color:#0000FF;
            cursor: pointer;
            text-decoration:underline;
        }
        .layui-table tr .td0{
            cursor: pointer;
            color:#0000FF;
            text-decoration:underline ;
        }
        .layui-table tr .td2,.layui-table tr .td5{
            text-align: left;
        }
        .layui-table tr .td2 a{
            display: block;
            width:100%;
            text-align: center;
        }
        .searchSureBtn{
            display:none
        }
        .formContent{
            height:auto;
           /* overflow-y: scroll;*/
        }
        .formContent center{
            margin-top:-10px;
        }
        .formContent center #table2{
            max-height:70%;
            width:100%;
        }
        .formContent center #pageBar2{
            position:absolute;
            top:0px;
            width:100%;
            text-align: center;
            display: none;
        }
        .formContent .layui-table tr td:first-child, .formContent .layui-table tr th:first-child{
            max-width:999px ;
            width:30px;
        }
    </style>
</head>
<body class="body">
<div id="loading">
    <img src='../styles/img/loading.gif' />
</div>
<div class="searchContainer">
    <div class="seachHeader">
        <span>成品编码：</span>
        <span class="centerInput centerInput1"></span>
        <span>项目编码：</span>
        <span class="centerInput centerInput2"></span>
        <span>供应商名称：</span>
        <span class="centerInput centerInput3"></span>
        <span><div class="searchSureButton ">搜索</div></span>
        <span><div class="searchSureBtn">导出Excel</div></span>
    </div>
    <div class="formContent">
    </div>
</div>
</body>
<script type="text/javascript" src="../js/jquery-1.11.3.min.js"></script>
<script src="../js/common/publicClass.js"></script>
<script src="../js/common/myAjax.js"></script>
<script src="../js/common/utils.js"></script>
<script src="../layer/layer.js" charset="utf-8"></script>
<script language="Javascript" src="../jqueryNicepage/js/layui.js"></script>
<script>
    maximizeWindow();//设置屏幕大小
    var tableText="";
    $(".centerInput1").append(setInput("请输入成品编码","",50,"text"));
    $(".centerInput2").append(setInput("请输入项目编码","",50,"text"));
    $(".centerInput3").append(setInput("请输入供应商名称","",50,"text"));
    var height=document.body.clientHeight;
    var width =document.body.clientWidth;
    $("#loading img").css({
        "margin-left":width/2-25+"px",
        "margin-top":height/2-25+"px"
    })
    focusOrBlur(".centerInput1");
    focusOrBlur(".centerInput2");
    focusOrBlur(".centerInput3");
    $('.centerInput input').bind('keyup', function(event) {
        if (event.keyCode == "13") {
            //回车执行查询
            searchFn();
        }
    });
    function searchFn(){
        if($(".centerInput1 input").val()!=""||$(".centerInput2 input").val()!=""||$(".centerInput3 input").val()!=""){
            var url = "/sqe/sqePart",
                    data="partNum="+encodeURIComponent($(".centerInput1 input").val().replace(/\s+/g,""))+"&proNum="+encodeURIComponent($(".centerInput2 input").val().replace(/\s+/g,""))+"&partSupplier="+encodeURIComponent($(".centerInput3 input").val().replace(/\s+/g,""));
            window.sqeExportExceldata=data;
            $("#loading").css({
                display:"block"
            });
            MaterialReverseAjax(url,data,suCallback);


        }else{
            layerFn("输入不能全部为空！");
        }
    }
    $(".searchSureButton").click(function(){
        searchFn();
    })
    function suCallback(str){
        $(".formContent").empty();
        $("#loading").css({
            display:"none"
        });
        if(str.fly!=undefined&&str.fly=="yes"){
            tableText="GYS"
            //window.open("sqeMateriel.html?partNum="+$.trim($(".centerInput1 input").val())+"&proNum="+$.trim($(".centerInput2 input").val())+"&partSupplier="+$.trim($(".centerInput3 input").val())+"&isRawMaterial=true")
            //window.open("sqeMateriel.html?partNum="+$.trim($(".centerInput1 input").val())+"&proNum="+$.trim($(".centerInput2 input").val())+"&partSupplier="+$.trim($(".centerInput3 input").val())+"&isRawMaterial=true");
            if(str.datalist!=undefined&&str.datalist.length>0){
                var dataListObjArr=[];
                for(var i=0;i<str.datalist.length;i++){
                    var dataListObj={};
                    dataListObj.partNumber=str.datalist[i].partNumber;
                    dataListObj.partName=str.datalist[i].partName;
                    //dataListObj.viewName=str.datalist[i].viewName;
                    dataListObj.partDescription=str.datalist[i].partDescription;
                    dataListObj.specialMonitor=str.datalist[i].specialMonitor;
                    dataListObj.whetherPartRecognize=str.datalist[i].whetherPartRecognize;
                    dataListObj.partSupplier=str.datalist[i].partSupplier;
                    dataListObjArr.push(dataListObj);
                }

                window.historyList1 =dataListObjArr;
                window.path=str.path;
                $(".searchSureBtn").css("display","block")
                window.headers1= ["序号","物料编号","物料名称","物料描述","是否专显","是否已经样品承认","供应商"] //table的列名
                window.widths1 = ['0',"100","200","300","100","100","200"]//table每列的宽度
              //  console.log($(".formContent").height());
                $(".formContent").empty().load('./newTable.html',"",function(){
                    setTimeout(function(){
                        var heightform=$(".searchContainer").height()-$(".seachHeader").height()-20;

                        if($(".formContent")[0].offsetHeight>(heightform*0.85)){
                            $("#pageBar2").css("top",heightform*0.85+$(".seachHeader").height()+30)
                        }else{
                            $("#pageBar2").css("top",$(".formContent")[0].offsetHeight+$(".seachHeader").height()+40);
                        }
                        $("#pageBar2").css("display","block")
                        $(".formContent").css({
                            "max-height":heightform*0.85,
                            "overflow-y":"scroll"
                        });
                        clearTimeout();
                    },200)
                });
            }

        }else if(str.datalist!=undefined&&str.datalist.length>0){
            $(".searchSureBtn").css("display","none")
            tableText="WL"
            var dataListObjArr=[];
            for(var i=0;i<str.datalist.length;i++){
                var dataListObj={};
                dataListObj.partNumber=str.datalist[i].partNumber;
                dataListObj.partName=str.datalist[i].partName;
                dataListObj.viewName="<a>"+str.datalist[i].viewName+"</a>";
                dataListObj.partDescription=str.datalist[i].partDescription;
                dataListObj.projectNumber=str.datalist[i].projectNumber;
                dataListObj.projectName=str.datalist[i].projectName;
                dataListObjArr.push(dataListObj);
            }
            window.historyList1=dataListObjArr;
            window.headers1=["序号","物料编号","物料名称","视图","物料描述","项目编码","项目名称"] //table的列名
            window.widths1=["100","200","200","100","200","100",100]
            $(".formContent").empty().load('./newTable.html',"",function(){
                setTimeout(function(){
                    var heightform=$(".searchContainer").height()-$(".seachHeader").height()-20;

                    if($(".formContent")[0].offsetHeight>(heightform*0.85)){
                        $("#pageBar2").css("top",heightform*0.85+$(".seachHeader").height()+20)
                    }else{
                        $("#pageBar2").css("top",$(".formContent")[0].offsetHeight+$(".seachHeader").height()+40);
                    }
                    $("#pageBar2").css("display","block")
                    $(".formContent").css({
                        "max-height":heightform*0.85,
                        "overflow-y":"scroll"
                    });
                    clearTimeout();
                },200)
            });
            $(document).unbind().on("click",".layui-table tr .td0",function(){
                var materielNum=$(this).text();
                var view=$($(this).parents("tr")).find("td:nth-child(4)").text();
                //if(view!=undefined)
                window.open("sqeMateriel.html?num="+materielNum+"&view="+view+"&isRawMaterial=true")
            })
        }else{
            $(".formContent").empty()
            var msg=str.message!=""&&str.message!=undefined?str.message:"您查询的数据不存在！";
            layerFn(msg);
        }
    }
    $('.searchSureBtn').click(function(){
        $("#loading").css({
            display:"block"
        });
        var flag=getQueryStringByNameTwo("isRawMaterial")
        if(flag!=undefined&&flag=="true"){
            var url = "/sqe/sqeMaterialExcel",
                    data="view="+view+"&number="+encodeURIComponent(num);

            MaterialReverseAjax(url,data,function(str){
                $("#loading").css({
                    display:"none"
                });
                if(str.status!=undefined&&str.status=="success"){
                    if(str.path!=undefined&&str.path!=""){
                        window.location.href=str.path;
                      //  window.open(str.path);
                    }

                }else{
                    var mesg=str.message!=undefined&&str.message!=""?str.message:"系统异常稍后重试"
                    layerFn(mesg);
                }
            });
        }else{
            var url='/sqe/sqeExportExcel';
            var datax=window.sqeExportExceldata;
            MaterialReverseAjax(url,datax,function(str){
                $("#loading").css({
                    display:"none"
                });
                if(str.status!=undefined&&str.status=="success"){
                    if(str.path!=undefined&&str.path!=""){
                        window.location.href=str.path;
                        //window.open(str.path);
                    }

                }else{
                    var mesg=str.message!=undefined&&str.message!=""?str.message:"系统异常稍后重试"
                    layerFn(mesg);
                }
            });
        }
    })
    $(".formContent").scroll(function() {
        var scrolltop=$(this).scrollTop();
        if(scrolltop>0){
            $("#table2 table thead").css({
                "position":"absolute",
                "background":"#f2f2f2",
                "opacity":"1",
                "z-index": 999,
                "top":$(".seachHeader").offsetHeight
            })
        }else{
            $("#table2 table thead").css({
                "position":""
            })
        }
        for (var i = 0; i <  window.headers1.length; i++) {
            var width = $("#table2 table tbody tr:first-child td").eq(i).width();
            if(tableText=="GYS"){
                if(i==3){
                    $("#table2 .layui-table thead tr:first-child th").eq(i).css({
                        "width": width+2.5
                    })
                }else if(i==4){
                    $("#table2 .layui-table thead tr:first-child th").eq(i).css({
                        "width": width+0
                    })
                }else{
                    $("#table2 .layui-table thead tr:first-child th").eq(i).css({
                        "width": width+1
                    })
                }
            }else{
                if(i==2||i==1||i==3||i==4||i==5||i==6){
                    $("#table2 .layui-table thead tr:first-child th").eq(i).css({
                        "width": width+0
                    })
                }else{
                    $("#table2 .layui-table thead tr:first-child th").eq(i).css({
                        "width": width+1
                    })
                }

            }
            if(IEVersion()>(8)){
                $("#table2 .layui-table thead tr:first-child th").eq(i).css({
                    "width": width
                })
            }else if(IEVersion()==(8)){
                $("#table2 .layui-table thead tr:first-child th").eq(i).css({
                    "width": width+1
                })
            }


        }
    })
    $(window).resize(function () { //当浏览器大小变化时
        //console.log($("#table2 table").width())
        $("#table2 table thead tr").css({
            "width":$("#table2 table").width()

        })
        var heightform=$(".searchContainer").height()-$(".seachHeader").height()-20;
        $(".formContent").css({
            "max-height":heightform*0.85,
            "overflow-y":"scroll"
        });
        if($(".formContent")[0].offsetHeight>(heightform*0.85)){
            $("#pageBar2").css("top",heightform*0.85+$(".seachHeader").height()+30)
        }else{
            $("#pageBar2").css("top",$(".formContent")[0].offsetHeight+$(".seachHeader").height()+40);
        }
        for (var i = 0; i <  window.headers1.length; i++) {
            var width = $("#table2 table tbody tr:first-child td").eq(i).width();
            if(tableText=="GYS"){
                if(i==3){
                    $("#table2 .layui-table thead tr:first-child th").eq(i).css({
                        "width": width+2.5
                    })
                }else if(i==4){
                    $("#table2 .layui-table thead tr:first-child th").eq(i).css({
                        "width": width+0
                    })
                }else{
                    $("#table2 .layui-table thead tr:first-child th").eq(i).css({
                        "width": width+1
                    })
                }
            }else{
                if(i==2||i==1||i==3||i==4||i==5||i==6){
                    $("#table2 .layui-table thead tr:first-child th").eq(i).css({
                        "width": width+0
                    })
                }else{
                    $("#table2 .layui-table thead tr:first-child th").eq(i).css({
                        "width": width+1
                    })
                }

            }
            if(IEVersion()>(8)){
                $("#table2 .layui-table thead tr:first-child th").eq(i).css({
                    "width": width
                })
            }else if(IEVersion()==(8)){
                $("#table2 .layui-table thead tr:first-child th").eq(i).css({
                    "width": width+1
                })
            }


        }
    });


</script>
</html>